﻿#include "MainWindow.h"
#include <QTabWidget>

MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);

	QTabWidget *tabWidget = new QTabWidget;
	this->setCentralWidget(tabWidget);
	
	tabWidget->addTab(curve_8(), "绘制8字曲线，点");
	tabWidget->addTab(no_margin(), "仅有绘图区域，无边框");
	tabWidget->addTab(set_color(), "设置各种区域颜色");
	tabWidget->addTab(test_selection(), "选中测试"); 
	tabWidget->addTab(add_png(), "添加一个图片");
	tabWidget->addTab(lineStyle(), "点样式demo");
}


void MainWindow::onCustomPlotClicked(QCPAbstractPlottable *plottable, int dataIndex, QMouseEvent *event)
{
	// 处理点击事件
	qDebug() << "Clicked on plot:" << plottable->name() << " at index" << dataIndex;

}

void MainWindow::set_graph_3_data(QCustomPlot *customPlot)
{
	{
		// 添加数据到曲线图
		QCPGraph* graph = customPlot->addGraph();
		graph->addData(3, 3);
		graph->addData(2, 3);
		QPen pen;
		pen.setWidth(10);
		pen.setBrush(QBrush(Qt::blue));
		graph->setPen(pen);
	}

	{
		// 添加数据到曲线图
		QCPGraph* graph = customPlot->addGraph();
		graph->addData(2, 2);
		graph->addData(2.4, 2);
		QPen pen;
		pen.setWidth(10);
		pen.setBrush(QBrush(Qt::green));
		graph->setPen(pen);
	}

	{
		// 添加数据到曲线图
		QCPGraph* graph = customPlot->addGraph();
		graph->addData(1, 1);
		graph->addData(3, 1);
		QPen pen;
		pen.setWidth(10);
		pen.setBrush(QBrush(Qt::red));
		graph->setPen(pen);
	}
}

QWidget * MainWindow::lineStyle()
{
	QCustomPlot *plot = new QCustomPlot;

	// QCP::iRangeDrag | QCP::iRangeZoom |
	plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
	plot->setMultiSelectModifier(Qt::KeyboardModifier::ControlModifier);



	std::vector<QCPGraph::LineStyle> list_type;
	for (int i = QCPGraph::LineStyle::lsNone; i <= QCPGraph::LineStyle::lsImpulse; i++)
	{
		QCPGraph::LineStyle line_type = (QCPGraph::LineStyle)i;
		list_type.push_back(line_type);

		QCPGraph *graph = plot->addGraph();
		graph->setLineStyle(line_type);

		// 设置图例名称
		graph->setName("图列"+QString::number(i)); //设置图例名字

		// 设置图表的画笔
		QPen pen;
		pen.setColor(QColor(qSin(i * 1 + 1.2) * 80 + 80, qSin(i*0.3 + 0) * 80 + 80, qSin(i*0.3 + 1.5) * 80 + 80));
		graph->setPen(pen);

		//设置散点为样式类型
		QCPScatterStyle mQCPScatterStyle((QCPScatterStyle::ScatterShape)i, 18);
		mQCPScatterStyle.setBrush(QBrush(Qt::red));
		mQCPScatterStyle.setPen(QPen(Qt::blue, 3));
		graph->setScatterStyle(mQCPScatterStyle);

		//数据
		for (int x = 0; x < 15; x++)
		{
			double y = 40 - i * 7 + abs(5 *  qSin(x));

			graph->addData(x, y);
			graph->rescaleAxes(true);
		}

	}
	//选中后，放大一点
	plot->xAxis->scaleRange(1.1, plot->xAxis->range().center());
	plot->yAxis->scaleRange(1.1, plot->yAxis->range().center());

	plot->xAxis->setTicks(true);
	plot->yAxis->setTicks(true);
	plot->xAxis->setTickLabels(true);
	plot->yAxis->setTickLabels(true);

	//标题元素
	plot->plotLayout()->insertRow(0);
	QCPTextElement *title = new QCPTextElement(plot, "数据与图例的选中，曲线的显示与隐藏，放大被框选数据", QFont("sans", 17, QFont::Bold));
	plot->plotLayout()->addElement(0, 0, title);

	plot->xAxis->setLabel("x轴");
	plot->yAxis->setLabel("y轴");

	plot->axisRect()->setupFullAxesBox();

	// 选择框
	plot->setSelectionRectMode(QCP::SelectionRectMode::srmSelect);
	plot->selectionRect()->setPen(QPen(Qt::red));

	plot->setMultiSelectModifier(Qt::KeyboardModifier::ControlModifier);

	// 设置图列可见
	plot->legend->setVisible(true);
	// 设置图列位置
	plot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop | Qt::AlignLeft);
	//设置图例背景
	plot->legend->setBrush(QColor(255, 255, 255, 150));
	// 设置边框隐藏
	plot->legend->setBorderPen(Qt::NoPen);
	// 设置图例行优先排列
	plot->legend->setFillOrder(QCPLayoutGrid::foColumnsFirst);
	// 设置六个图例自动换行
	plot->legend->setWrap(6);
	// 设置图例位置，这里选择显示在QCPAxisRect下方，同理可设置显示在QCustomPlot中任意位置
	plot->plotLayout()->addElement(2, 0, plot->legend);
	// 设置显示比例
	plot->plotLayout()->setRowStretchFactor(2, 0.001);



	//先连接选中线条信号 -- 设置图列同步选中
	connect(plot, &QCustomPlot::selectionChangedByUser, this, [=]
	{
		for (int i = 0; i < plot->graphCount(); ++i)
		{
			//获取图例
			QCPPlottableLegendItem *item = plot->legend->itemWithPlottable(plot->graph(i));
			if (plot->graph(i)->selected())  //线条选中
			{
				item->setSelected(true);
			}
			else
			{
				item->setSelected(false);
			}
		}
	});
	return plot;
}

QWidget * MainWindow::add_png()
{
	QCustomPlot *plot = new QCustomPlot;
	//plot->axisRect()->setBackground(QPixmap(":/MainWindow/Resources/2022-10-26 16-45-14-39.png"));//背景图片
	plot->setMultiSelectModifier(Qt::ControlModifier);
	plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables | QCP::iMultiSelect);

	// 在指定的位置添加一个图片
	QPixmap pixmap(":/MainWindow/Resources/2022-10-26 16-45-14-39.png");
	// 创建QCPItemPixmap对象并将其添加到图形中
	QCPItemPixmap *itemPixmap = new QCPItemPixmap(plot);
	itemPixmap->setPixmap(pixmap);
	itemPixmap->setScaled(true);
	itemPixmap->setClipToAxisRect(false);
	// 设置图片的位置和大小
	QSize size = pixmap.size()/100;
	itemPixmap->topLeft->setCoords(0, size.height() );
	itemPixmap->bottomRight->setCoords(size.width(), 0);

	//标题元素
	plot->plotLayout()->insertRow(0);
	QCPTextElement *title = new QCPTextElement(plot, "指定位置图片不能放太大--会卡", QFont("sans", 17, QFont::Bold));
	plot->plotLayout()->addElement(0, 0, title);

	return plot;
}

QWidget * MainWindow::test_selection()
{
	QCustomPlot *plot = new QCustomPlot;

	// QCP::iRangeDrag | QCP::iRangeZoom |
	plot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
	plot->setMultiSelectModifier(Qt::KeyboardModifier::ControlModifier);

	std::vector<QCPGraph::LineStyle> list_type;
	for (int i = QCPGraph::LineStyle::lsNone; i <= QCPGraph::LineStyle::lsImpulse; i++)
	{
		QCPGraph::LineStyle line_type = (QCPGraph::LineStyle)i;
		list_type.push_back(line_type);

		QCPGraph *graph = plot->addGraph();
		graph->setLineStyle(line_type);

		// 选中数据的范围 -- 单独的点等
		graph->setSelectable(QCP::SelectionType::stMultipleDataRanges);

		// 设置图例名称
		graph->setName("图列" + QString::number(i)); //设置图例名字

												   // 设置图表的画笔
		QPen pen;
		pen.setColor(QColor(qSin(i * 1 + 1.2) * 80 + 80, qSin(i*0.3 + 0) * 80 + 80, qSin(i*0.3 + 1.5) * 80 + 80));
		graph->setPen(pen);

		//设置散点为样式类型
		QCPScatterStyle mQCPScatterStyle((QCPScatterStyle::ScatterShape)i, 18);
		mQCPScatterStyle.setBrush(QBrush(Qt::red));
		mQCPScatterStyle.setPen(QPen(Qt::blue, 3));
		graph->setScatterStyle(mQCPScatterStyle);
		graph->setSelectable(QCP::SelectionType::stMultipleDataRanges);
		//数据
		for (int x = 0; x < 15; x++)
		{
			double y = 40 - i * 7 + abs(5 * qSin(x));

			graph->addData(x, y);
			graph->rescaleAxes(true);
		}

	}
	plot->setSelectionRectMode(QCP::SelectionRectMode::srmSelect);
	plot->selectionRect()->setPen(QPen(Qt::black, 1, Qt::DashLine));
	plot->selectionRect()->setBrush(QBrush(QColor(0, 0, 100, 50)));
	plot->setInteractions(QCP::iRangeZoom | QCP::iSelectPlottables | QCP::iMultiSelect);//
	//选中后，放大一点
	plot->xAxis->scaleRange(1.1, plot->xAxis->range().center());
	plot->yAxis->scaleRange(1.1, plot->yAxis->range().center());

	plot->setInteraction(QCP::iRangeDrag, false);//取消拖动
	plot->setSelectionRectMode(QCP::SelectionRectMode::srmSelect);

	plot->xAxis->setTicks(true);
	plot->yAxis->setTicks(true);
	plot->xAxis->setTickLabels(true);
	plot->yAxis->setTickLabels(true);

	//标题元素
	plot->plotLayout()->insertRow(0);
	QCPTextElement *title = new QCPTextElement(plot, "数据与图例的选中，曲线的显示与隐藏，放大被框选数据", QFont("sans", 17, QFont::Bold));
	plot->plotLayout()->addElement(0, 0, title);

	plot->xAxis->setLabel("x轴");
	plot->yAxis->setLabel("y轴");

	plot->axisRect()->setupFullAxesBox();

	// 选择框
	plot->setSelectionRectMode(QCP::SelectionRectMode::srmSelect);
	plot->selectionRect()->setPen(QPen(Qt::red));

	plot->setMultiSelectModifier(Qt::KeyboardModifier::ControlModifier);

	// 设置图列可见
	plot->legend->setVisible(true);
	// 设置图列位置
	plot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop | Qt::AlignLeft);
	//设置图例背景
	plot->legend->setBrush(QColor(255, 255, 255, 150));
	// 设置边框隐藏
	plot->legend->setBorderPen(Qt::NoPen);
	// 设置图例行优先排列
	plot->legend->setFillOrder(QCPLayoutGrid::foColumnsFirst);
	// 设置六个图例自动换行
	plot->legend->setWrap(6);
	// 设置图例位置，这里选择显示在QCPAxisRect下方，同理可设置显示在QCustomPlot中任意位置
	plot->plotLayout()->addElement(2, 0, plot->legend);
	// 设置显示比例
	plot->plotLayout()->setRowStretchFactor(2, 0.001);

	//先连接选中线条信号 -- 设置图列同步选中
	connect(plot, &QCustomPlot::selectionChangedByUser, this, [=]
	{
		for (int i = 0; i < plot->graphCount(); ++i)
		{
			//获取图例
			QCPPlottableLegendItem *item = plot->legend->itemWithPlottable(plot->graph(i));
			if (plot->graph(i)->selected())  //线条选中
			{
				item->setSelected(true);
			}
			else
			{
				item->setSelected(false);
			}
		}
	});
	connect(plot, &QCustomPlot::selectionChangedByUser, this, [=]
	{
		qDebug() << "selectionChangedByUserslot";

		for (int i = 0; i < plot->graphCount(); i++)
		{
			if (plot->graph(i)->selected())
			{
				QCPDataSelection selection = plot->graph(i)->selection();
				//遍历选中范围
				for (int j = 0; j < selection.dataRangeCount(); j++)
				{
					QCPDataRange dataRange = selection.dataRange(j);
					//遍历数据
					for (int k = dataRange.begin(); k < dataRange.end(); k++)
					{
						double key = plot->graph(i)->data()->at(k)->key;
						double value = plot->graph(i)->data()->at(k)->value;
						int a = 1;
						qDebug() << "key:" << key << "value:" << value;
					}
				}
			}
		}
	});


	return plot;
}


QWidget * MainWindow::set_color()
{
	QCustomPlot *customPlot = new QCustomPlot;
	/*
	QCP::iRangeDrag			拖拽
	QCP::iRangeZoom         缩放
	QCP::iSelectPlottables  选中
	*/
	customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
	customPlot->setMultiSelectModifier(Qt::KeyboardModifier::ControlModifier);
	set_graph_3_data(customPlot);

	customPlot->setBackground(QBrush(Qt::gray));
	customPlot->axisRect()->setBackground(Qt::white);


	int val = 3;
	//设置坐标文本颜色   
	customPlot->xAxis->setTickLabelColor(Qt::white);
	customPlot->yAxis->setTickLabelColor(Qt::white);

	//设置坐标名称文本颜色
	customPlot->xAxis->setLabelColor(Qt::yellow);
	customPlot->yAxis->setLabelColor(Qt::cyan);
	//设置坐标轴名称
	customPlot->xAxis->setLabel("时间轴");
	customPlot->yAxis->setLabel("温度(℃)");

	//设置label字体
	QFont xFont = customPlot->xAxis->labelFont();
	xFont.setPixelSize(40);
	customPlot->xAxis->setLabelFont(xFont);
	customPlot->yAxis->setBasePen(QPen(Qt::white));
	customPlot->yAxis->setTickPen(QPen(Qt::white));
	customPlot->yAxis->setSubTickPen(QPen(Qt::white));

	// 轴矩形背景使用图片
	customPlot->axisRect()->setBackgroundScaled(false);//启用背景缩放 
	customPlot->axisRect()->setBackgroundScaledMode(Qt::AspectRatioMode::IgnoreAspectRatio);//自由缩放
	customPlot->axisRect()->setBackground(QPixmap(":/MainWindow/Resources/2022-10-26 16-45-14-39.png"));//背景图片

	//设置坐标轴颜色
	customPlot->xAxis->setBasePen(QPen(Qt::red, val));
	// 刻度线长度
	customPlot->xAxis->setTickPen(QPen(Qt::green, val));
	customPlot->xAxis->setTickLengthIn(30);//主刻度向内延伸30
	customPlot->xAxis->setTickLengthOut(10);//主刻度向外延伸10
	customPlot->xAxis->setSubTickPen(QPen(Qt::blue, val));
	customPlot->xAxis->setSubTickLengthIn(15);//子刻度向内延伸15
	customPlot->xAxis->setSubTickLengthOut(5);//子刻度向外延伸5


	//网格线颜色
	customPlot->xAxis->setRange(-10, 50);
	customPlot->xAxis->ticker()->setTickOrigin(10);//改变刻度原点为1
	customPlot->axisRect()->setBackground(QBrush(Qt::black));//背景黑色
	customPlot->xAxis->grid()->setPen(QPen(Qt::red, 1, Qt::PenStyle::DashLine));//网格白色虚线
	customPlot->xAxis->grid()->setSubGridPen(QPen(Qt::cyan, 1, Qt::DotLine));//网格浅色点线
	customPlot->xAxis->grid()->setSubGridVisible(true);//显示x轴子网格线
	customPlot->xAxis->grid()->setZeroLinePen(QPen(Qt::yellow));//x轴0线颜色白色

// 	customPlot->yAxis->grid()->setPen(QPen(QColor(180, 180, 180), 1, Qt::PenStyle::DashLine));//网格白色虚线
// 	customPlot->yAxis->grid()->setSubGridPen(QPen(QColor(50, 50, 50), 1, Qt::DotLine));//网格浅色点线
// 	customPlot->yAxis->grid()->setSubGridVisible(true);//显示要轴子网格线
// 	customPlot->yAxis->grid()->setZeroLinePen(QPen(Qt::white));//y轴0线颜色白色

	// 刻度值格式
	customPlot->xAxis->setNumberFormat("gbc");//g灵活的格式,b漂亮的指数形式，c乘号改成×
	customPlot->xAxis->setNumberPrecision(1);//精度1

	// 刻度数量
	customPlot->xAxis->ticker()->setTickCount(8);//11个主刻度
	customPlot->xAxis->ticker()->setTickStepStrategy(QCPAxisTicker::tssReadability);//可读性优于设置

	// 坐标轴偏移
	customPlot->xAxis->setPadding(50);//填充50的空间
	customPlot->xAxis->setOffset(50);//偏移50

	//刻度值显示
	customPlot->xAxis->setTickLabels(true);//显示刻度值
	customPlot->yAxis->setTickLabelSide(QCPAxis::LabelSide::lsInside);//显示在内部

	//线结尾装饰
	customPlot->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);//x轴终点箭头图案
	customPlot->xAxis->setLowerEnding(QCPLineEnding::esDisc);//x轴起点圆点图案
	customPlot->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);//y轴终点小方块图案
	customPlot->yAxis->setLowerEnding(QCPLineEnding::esSquare);//y轴起点圆点图案

	return customPlot;
}

QWidget * MainWindow::no_margin()
{
	QCustomPlot *customPlot = new QCustomPlot;
	/*
	QCP::iRangeDrag			拖拽
	QCP::iRangeZoom         缩放
	QCP::iSelectPlottables  选中
	*/

	set_graph_3_data(customPlot);

	customPlot->setInteractions(QCP::iSelectPlottables);
	customPlot->setMultiSelectModifier(Qt::KeyboardModifier::ControlModifier);
	customPlot->setBackground(QBrush(Qt::cyan));
	customPlot->axisRect()->setBackground(Qt::white);
	customPlot->axisRect()->setupFullAxesBox(false);
	customPlot->xAxis->setVisible(false);
	customPlot->yAxis->setVisible(false);
	customPlot->xAxis2->setVisible(false);
	customPlot->yAxis2->setVisible(false);


	customPlot->axisRect()->setAutoMargins(QCP::MarginSide::msNone);
	// 下方显示了背景色
	customPlot->axisRect()->setMargins(QMargins(0, 0, 0, 40));

	//customPlot->plotLayout()->setAutoMargins(QCP::MarginSide::msNone);
	//customPlot->plotLayout()->setMinimumMargins(QMargins(0,0,0,0));
	return customPlot;
}

QWidget * MainWindow::curve_8()
{
	QCustomPlot *customPlot = nullptr;
	QCPCurve *curve = nullptr;
	auto reset_curve = [=](QCustomPlot *customPlot, QCPCurve **curve)
	{
		// 清空cure	
		if (!*curve)
		{
			customPlot->removePlottable(*curve);
		}

		*curve = new QCPCurve(customPlot->xAxis, customPlot->yAxis);
		(*curve)->setLineStyle(QCPCurve::LineStyle::lsLine);

		//设置散点为样式类型
		QCPScatterStyle mQCPScatterStyle(QCPScatterStyle::ScatterShape::ssCircle, 10);
		mQCPScatterStyle.setBrush(QBrush(Qt::red));
		mQCPScatterStyle.setPen(QPen(Qt::blue, 1));
		(*curve)->setScatterStyle(mQCPScatterStyle);

		(*curve)->setSelectable(QCP::SelectionType::stMultipleDataRanges); // 选中多个点

		// 选中的样式
		{
			//设置散点为样式类型
			QCPScatterStyle mQCPScatterStyle(QCPScatterStyle::ScatterShape::ssCircle, 13);
			mQCPScatterStyle.setBrush(QBrush(Qt::red));
			mQCPScatterStyle.setPen(QPen(Qt::blue, 5));
			(*curve)->selectionDecorator()->setPen(QPen(Qt::red));
			(*curve)->selectionDecorator()->setScatterStyle(mQCPScatterStyle);
			(*curve)->setSelection(QCPDataSelection((*curve)->data()->dataRange()));
		}
	};

	customPlot = new QCustomPlot;
	customPlot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom | QCP::iSelectPlottables);
	customPlot->setSelectionRectMode(QCP::SelectionRectMode::srmSelect);
	customPlot->xAxis->setRange(-10, 10);
	customPlot->yAxis->setRange(-10, 10);
		
	reset_curve(customPlot, &curve);

	double scale = 5;
	double dph = 2 * M_PI / 30;
	for (double t = 0; t < 2 * M_PI; t += dph)
	{
		double a = 0.3;                                 // % 控制横轴上的范围
		double x = a * qCos(t) / (1 + qSin(t)*qSin(t));
		double y = qSin(t)*qCos(t)  / (1 + qSin(t)*qSin(t));// % 当然可以乘一个系数放大纵轴范围

		curve->addData(t, x*scale, y*scale);
	}

	set_move(customPlot);

	return customPlot;
}

void MainWindow::set_move(QCustomPlot *customPlot)
{
	QCPGraph *graph = customPlot->addGraph();
	graph->setBrush(QBrush(QColor(0, 0, 255, 20)));
	graph->addData(2, 2);
	graph->addData(4, 3);
	graph->addData(4, 2);
	QCPGraph *graph_move = customPlot->addGraph();
	graph_move->setPen(QPen(Qt::red, 3, Qt::PenStyle::DotLine));

	static bool press = false;
	connect(customPlot, &QCustomPlot::mouseRelease, this, [=](QMouseEvent *event)
	{
		press = false;
	});
	connect(customPlot, &QCustomPlot::mousePress, this, [=](QMouseEvent *event)
	{
		//获取鼠标坐标点
		QPointF chickedPoint = event->pos();
		//排除区间外点
		if (customPlot->viewport().contains(event->pos()))
		{
			//鼠标点击的后位置转换到下坐标轴对应坐标
			int16_t current_Rx = customPlot->xAxis->pixelToCoord(chickedPoint.x());
			int16_t current_Ry = customPlot->yAxis->pixelToCoord(chickedPoint.y());

			//获取实部y轴的显示范围
			double y_Vrange = (customPlot->yAxis->range().size()) / 100;
			double x_range = (customPlot->xAxis->range().size()) / 50;

			graph->data().data()->clear();
			graph->addData(2, 2);
			graph->addData(current_Rx, 3);
			graph->addData(current_Rx, 2);
		}



		customPlot->replot();

		press = true;
	});


	connect(customPlot, &QCustomPlot::mouseMove, this, [=](QMouseEvent *event)
	{
		if (press)
		{
			//获取鼠标坐标点
			QPointF chickedPoint = event->pos();
			//排除区间外点
			if (customPlot->viewport().contains(event->pos()))
			{
				//鼠标点击的后位置转换到下坐标轴对应坐标
				int16_t current_Rx = customPlot->xAxis->pixelToCoord(chickedPoint.x());
				int16_t current_Ry = customPlot->yAxis->pixelToCoord(chickedPoint.y());

				//获取实部y轴的显示范围
				double y_Vrange = (customPlot->yAxis->range().size()) / 100;
				double x_range = (customPlot->xAxis->range().size()) / 50;

				graph->data().data()->clear();
				graph->addData(2, 2);
				graph->addData(current_Rx, 3);
				graph->addData(current_Rx, 2);

				graph_move->data().data()->clear();
				graph_move->addData(current_Rx, 10);
				graph_move->addData(current_Rx, -10);
				customPlot->replot();
			}
		}
		else
		{

			//获取鼠标坐标点
			QPointF chickedPoint = event->pos();
			//排除区间外点
			if (customPlot->viewport().contains(event->pos()))
			{
				//鼠标点击的后位置转换到下坐标轴对应坐标
				int16_t current_Rx = customPlot->xAxis->pixelToCoord(chickedPoint.x());
				int16_t current_Ry = customPlot->yAxis->pixelToCoord(chickedPoint.y());

				//获取实部y轴的显示范围
				double y_Vrange = (customPlot->yAxis->range().size()) / 100;
				double x_range = (customPlot->xAxis->range().size()) / 50;

				graph_move->data().data()->clear();
				graph_move->addData(current_Rx, 10);
				graph_move->addData(current_Rx, -10);
				customPlot->replot();
			}
		}
	});


}
